﻿using System.Collections.Generic;
using Drill.Configuration;
using Drill.Core;
using Drill.Extensibility;

namespace Drill.DrillBits.StructureMap.TestHelpers
{
	public static class StructureMapTestConfigs
	{
		public static DependencyResolverConfiguration CreateStructureMapDependencyResolverConfigurationWithSetupProvider()
		{
			return 
			new DependencyResolverConfiguration
				{
					SearchPaths = 
						new SearchPathConfigurationCollection
							{
								new SearchPathConfiguration
									{
										Enabled = true
										, Path = @"..\..\..\..\..\TestData\StructureMapProvider"
									}
							}
					, DrillBits = 
						new DrillBitConfigurationCollection
							{
								new DrillBitConfiguration
									{
										ConfigurationSources = 
											new ConfigSourceConfigurationCollection
												{
													new ConfigSourceConfiguration
														{
															Enabled = true
															, Key = "StructureMapSetupProvider"
															, Method = DrillBitConfigMethod.DrillBitSetup
															, Value = "Drill.DrillBits.StructureMap.TestHelpers.StructureMapDrillBitSetupTestClass, Drill.DrillBits.StructureMap.Tests"
														}
												}
										, Enabled = true
										, Name = "Default"
										, Type = "Drill.DrillBits.StructureMap.StructureMapDrillBit, Drill.DrillBits.StructureMap"
									}
							}
					, Enabled = true
					, Name = "Default"
					, Type = null
				};
		}

		public static DependencyResolverConfiguration CreateStructureMapDependencyResolverConfigurationWithDefaultConfigurationSource()
		{
			return
			new DependencyResolverConfiguration
			{
				SearchPaths =
					new SearchPathConfigurationCollection
							{
								new SearchPathConfiguration
									{
										Enabled = true
										, Path = @"..\..\..\..\..\TestData\StructureMapProvider"
									}
							}
				,
				DrillBits =
				  new DrillBitConfigurationCollection
							{
								new DrillBitConfiguration
									{
										ConfigurationSources = 
											new ConfigSourceConfigurationCollection
												{
													new ConfigSourceConfiguration
														{
															Enabled = true
														  , Key = "StructureMapDefaultConfig"
														  , Method = DrillBitConfigMethod.Default
														  , Value = null
														}
												}
										, Enabled = true
										, Name = "Default"
										, Type = "Drill.DrillBits.StructureMap.StructureMapDrillBit, Drill.DrillBits.StructureMap"
									}
							}
				,
				Enabled = true
				,
				Name = "Default"
				,
				Type = null
			};
		}

		public static IDrillBitInitContext CreateStructureMapProviderInitializationContext()
		{
			return
				new DrillBitInitContext
				{
					ConfigurationSources =
						new List<IConfigurationSource>
								{
									new ConfigurationSource
										{
											ConfigurationMethod = DrillBitConfigMethod.Default
										  , ConfigurationObject = null
										  , Key = "StructureMapDefaultConfig"
										}
								}
				  , ConfigurationHelper =
						new ConfigurationHelperFactory()
							.CreateConfigurationHelper(
								new List<IRootPathProvider> { new ExecutingDirectoryRootPathProvider() }
							  , new List<ISearchPath> { new SearchPath { Value = @"..\..\..\..\..\TestData\StructureMapProvider" } }
								)
				  , Name = "Default"
				};
		}
	}
}